﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NearForums.DataAccess;

namespace NearForums.Services
{
    public class AskQuestionService:IAskQuestionService
    {
        private readonly IAskQuestionDataAccess _dataAccess;

        public AskQuestionService(IAskQuestionDataAccess da)
        {
            _dataAccess = da;
        }

        public List<Questions> GetAllQuestionsByPage(int pageSize, int pageNum)
        {
            return _dataAccess.GetAllQuestionsByPage(pageSize, pageNum);
        }

        public void Add(Questions q, int forumId, int userID)
        {
            q.ValidateFields();
            _dataAccess.Add(q, forumId, userID);
        }

        public void Update(Questions q, int forumId)
        {
            q.ValidateFields();
            _dataAccess.Update(q, forumId);
        }

        public void Delete(int questionID)
        {
            _dataAccess.Delete(questionID);
        }

        public List<Questions> GetReletedQuestion(string keyword, Questions q)
        {
           return _dataAccess.GetReletedQuestion(keyword, q);
        }


        public void AddVisit(int questionId)
        {
            _dataAccess.AddVisit(questionId);
        }

        public Questions GetQuestionById(int id)
        {
            return _dataAccess.GetQuestionById(id);
        }
    }
}
